function ImageUpload(picNames,fileFolder,suffix,context_path,inputName){
	this.already_pixel_array = new Array();
	this.already_pic_names_array = picNames==""?new Array():picNames.split(",");
	this.files_folder = fileFolder;
	this.el_suffix = suffix;
	this.context_path = context_path;
	this.already_pixel_array = new Array();
	this.need_add_pic_pixel = new Array();
	this.remove_pic_names_array = new Array();
	this.pic_id_index = 0;
	this.inputName = inputName;
	if(arguments.length==6)
		this.all_pixel_array = arguments[5]==""?new Array():arguments[5].split(",");
	else
		this.all_pixel_array = ["256_176"];
	for (var i in this.all_pixel_array) {
		if ($.inArray(this.all_pixel_array[i],this.already_pixel_array) == -1)
			this.need_add_pic_pixel.push(this.all_pixel_array[i]);
	}
	for (var i in this.already_pic_names_array) {
		var tempStr = this.already_pic_names_array[i].split("_");
		this.already_pixel_array.push(tempStr[1]+"_"+tempStr[2]);
		var index = $.inArray(tempStr[1]+"_"+tempStr[2],this.need_add_pic_pixel);
		if(index!=-1)
			this.need_add_pic_pixel.splice(index,1);
	}
	$('<input type="hidden" name="'+this.allStrInpName+this.el_suffix+'"/>').appendTo($("#pic_content_div"+this.el_suffix));
	$('<input type="hidden" name="'+this.inputName+'"/>').appendTo($("#pic_content_div"+this.el_suffix));
	this.showNeedAddPicPixel();
}
ImageUpload.prototype.allStrInpName="imageUploadAllPicStrs";
ImageUpload.prototype.showNeedAddPicPixel=function(){
	if (this.need_add_pic_pixel.length==0) {
		$("#pic_need_add_pixel_div"+this.el_suffix).html("<b>图片已添加完成！</b>");
	}
	else {
		$("#pic_need_add_pixel_div"+this.el_suffix).html("<b>需要上传的图片像素列表：</b>"+this.need_add_pic_pixel.join("，"));
	}
};
ImageUpload.prototype.openAddImgFrame=function(){
	if (this.need_add_pic_pixel.length==0){
		alert("所有像素的图片都已添加完成！");
		return;
	}
	var add_pic_href = $("#add_pic_a_id"+this.el_suffix).attr("href");
	var temp_href="?suffix="+this.el_suffix+"&folder="+this.files_folder+"&pixels="+this.need_add_pic_pixel.join(",")+"&alreadyPixels="+this.already_pixel_array.join(",");
	if (add_pic_href.indexOf("?")!=-1){
		add_pic_href = add_pic_href.substring(0,add_pic_href.indexOf("?"));
	}
	$("#add_pic_a_id"+this.el_suffix).attr("href",add_pic_href+temp_href);
	$('#add_pic_a_id'+this.el_suffix).trigger('click');
};
ImageUpload.prototype.confirmAddPicContent=function(args){
	var fileName = args["fileName"];
	var fileSize = args["fileSize"];
	var temp = fileName.split("_");
	var width = temp[1];
	var height = temp[2];
	var arg1 = "pic_div_content_" + this.el_suffix + "_" + this.pic_id_index;
	var arg2 = width+'_'+height;
	var arg3 = fileName;
	var str = '<div id="'+arg1+'" style="border:1 solid #ccc;margin-top:5px;margin-bottom:5px;padding:5px;width:700px">';
	str += '<b>图片像素：</b>宽'+width+'高'+height;
	str += '<b style="margin-left:15px">图片大小：</b>'+fileSize+'KB<b style="margin-left:15px">图片：</b>';
	str += '<a href="'+this.context_path+'/jsp/common/preview_image.jsp?folder='+this.files_folder+'&picNames='+fileName+'" target="dialog" max="true" title="预览图片" width="800" height="480" style="margin-right: 40px">'+fileName+'</a>';
	str += '<a href="javascript:;" onclick="removePicContent(\''+arg1+'\',\''+arg2+'\',\''+arg3+'\',\''+this.el_suffix+'\');">移除</a></div>';
	$(str).appendTo($("#pic_content_div"+this.el_suffix));
	this.pic_id_index += 1;
	this.addNewPic(arg2,fileName);
	this.showNeedAddPicPixel();
};
ImageUpload.prototype.addNewPic=function(w_h,fileName){
	this.already_pixel_array.push(w_h);
	this.already_pic_names_array.push(fileName);
	var index = $.inArray(w_h,this.need_add_pic_pixel);
	if(index!=-1)this.need_add_pic_pixel.splice(index,1);
};
ImageUpload.prototype.removePicContent=function(remove_id,w_h,fileName){
	$("#"+remove_id).remove();
	if($.inArray(w_h,this.all_pixel_array)!=-1)
		this.need_add_pic_pixel.push(w_h);
	var index = $.inArray(fileName,this.already_pic_names_array);
	if(index!=-1)this.already_pic_names_array.splice(index,1);
	index=$.inArray(w_h,this.already_pixel_array);
	if(index!=-1)this.already_pixel_array.splice(index,1);
	this.remove_pic_names_array.push(fileName);
	this.showNeedAddPicPixel();
};
ImageUpload.prototype.validate=function(){
	if (this.need_add_pic_pixel.length>0)
		return false;
	var fileNames = this.already_pic_names_array.join(",");
	$("input[name='"+this.inputName+"']").val(fileNames);
	var removeFileNames = this.remove_pic_names_array.join(",");
	$("input[name='"+(this.allStrInpName+this.el_suffix)+"']").val(this.files_folder + "FG" + removeFileNames + "FG" + fileNames);
	return true;
};
function confirmAddPicContent(args,suffix){
	eval("iu"+suffix).confirmAddPicContent(args);
}
function removePicContent(removeId,w_h,fileName,suffix){
	eval("iu"+suffix).removePicContent(removeId,w_h,fileName);
}
function openAddImgFrame(suffix){
	eval("iu"+suffix).openAddImgFrame();
}